<?php
// +----------------------------------------------------------------------
// | EtrolPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Author:HCZ <huangchengze@etrol.com>
// +-----------------------------------------------------------------------

namespace app\common\model;

use app\common\model\Base;
/**
 * 审核事项
 */
class Wfitem extends Base{
	protected $name = 'wfiteminfo';
	
	protected $wfTypeToData = [
			1  => 'rehearse/plan',
			2  => '',
			3  => 'basic/danger',
			4  => 'plan/plan',
			5  => 'plan/plan',
			6  => 'basic/hazard',
			7  => 'basic/technology',
			8  => 'basic/unit',
			9  => 'basic/rescue',
			10 => 'basic/equipe',
			11 => 'basic/enterprise',
			12 => 'basic/craft',
			13 => 'duty/news',
	];
	
	
	public function getTypeList(){
		return db('basicinfo')->where('sysCode',29)->column('subsystemName','subsystemNo');
	}
	
	public function getwfTypeAttr($value,$data){
		$typeList = $this->getTypeList();
		if($data['wfType']){
			return $typeList[$data['wfType']];
		}
		return null;
	}
	
	public function getwfTypeIdAttr($value,$data){
		return $data['wfType'];
	}
	public function getBusiModelAttr($value,$data){
		if ($data['wfType']){
			return $this->wfTypeToData[$data['wfType']];
		}
		return null;
	}
	
	public function workflow(){
		return $this->hasOne('workflow','id','wfFlowInfoId');
	}
	
	public function processes(){
		return $this->hasMany('Wfprocess','wfItemInfoId','id');
	}
}